<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        [v-cloak] {
            display: none;
        }
    </style>
    <script type='text/javascript' src='../js/vue.js'></script>
    <script type='text/javascript' src=''></script>

</head>

<body>
    <!-- 
        1、组件命名：
            one word：
                school  
                School
            many words:
                my-school
                MySchool
            （1）组件名尽可能回避HTML中已有的元素名称
            （2）可以使用name配置项指定开发者工具中的组件名
        2、
            单标签自闭合使用 ：页面只显示一个
        3、简写方式：
            const school = Vue.extend(options) 可简写为：const school = options
     -->
    <div id="root">
        <school></school>
        <hr/>
        <school/>
        <school/> 
        <school/>
        <school/>
    </div>
    <script>
        Vue.config.productionTip = false;

        const schoolSimple = {
            name:'SONG',
            template: `
                <div>
                    <h2>学校名称：{{schoolName}}</h2>
                    <h2>学校地址：{{address}}</h2>
                    <button @click='showName'>点我提示学校名</button>
                </div>
            `,
            data() {
                return {
                    schoolName: 'CQBZ',
                    address: 'CQ',
                }
            },
            methods:{
                showName(){
                    alert(this.schoolName)
                }
            }
        }

        const school = Vue.extend({
            name:'SONG',
            template: `
                <div>
                    <h2>学校名称：{{schoolName}}</h2>
                    <h2>学校地址：{{address}}</h2>
                    <button @click='showName'>点我提示学校名</button>
                </div>
            `,
            data() {
                return {
                    schoolName: 'CQBZ',
                    address: 'CQ',
                }
            },
            methods:{
                showName(){
                    alert(this.schoolName)
                }
            }
        })

       
        new Vue({
            el: '#root',
            // 注册组件，局部注册
            components: {
                school: school
            }
        })

    </script>
</body>

</html>